<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" id="viewportId" content="width=device-width,initial-scale=1.0,maximum-scale=1.0"/>
    <meta name="applicable-device" content="pc,mobile">
    <title><?php echo $global_config['title']; ?></title>
    <meta name="keywords" content="<?php echo $global_config['keywords'];?>" />
    <meta name="description" content="<?php echo $global_config['description'];?>" />
    <link type="text/css" href="__PUBLIC__/Home/css/bootstrap.min.css" rel="stylesheet"/>
    <link type="text/css" href="__PUBLIC__/Home/css/bass.css" rel="stylesheet"/>
    <link type="text/css" href="__PUBLIC__/Home/css/hdft.css" rel="stylesheet"/>
    <link type="text/css" href="__PUBLIC__/Home/css/dl.css" rel="stylesheet"/>
	<script type="text/javascript" src="__PUBLIC__/Home/js/jquery-1.9.1.min.js" charset="UTF-8"></script>
	<script type="text/javascript" src="__PUBLIC__/Home/js/bootstrap.min.js" charset="UTF-8"></script>
</head>
<body>
    <div class="ls-wrap">
        <include file="Public/nav"/>
        <!--内容 start-->
        <div class="ls-body">
            <div class="dlbody bgdetail">
                <div class="bbsbody fitw forumbody">
                    <div class="forum-tit"><?php echo $topic_info['name']; ?></div>
                    <div class="forum-con">
                        <ul class="forumlist">
                            <?php foreach($list as $item) { ?>
                            <li class="forumli">
                                <div class="forumli-hd">
                                    <span class="name"><?php echo $item['user_name']; ?></span>
                                    <span class="time"><?php echo $item['create_time']; ?></span>
                                </div>
                                <div class="forumli-txt"><?php echo $item['content']; ?></div>
                            </li>
                            <?php } ?>
                        </ul>
                    </div>
                    <!--留言板-->
                    <div class="forumpop">
                        <form id="J_Form" name="comment-form" action="<?php echo U('Forum/add'); ?>">
                        <div class="forumpop-body">
                            <div class="notetit">我要回答</div>
                            <div class="notehd">
                                <span class="notehd-in">
                                    <em>电话：</em><input type="text" id="phone" class="inframe" placeholder="发布后会自动隐藏">
                                </span>
                                <span class="notehd-in">
                                    <em>用户名：</em><input type="text" id="user_name" class="inframe" placeholder="用户名必填...">
                                </span>
                            </div>
                            <div class="notetxt">
                                <textarea class="inarea style1" id="content" placeholder="请输入.."></textarea>
                            </div>
                        </div>
                        <div class="ls-handle">
                            <a class="lsbtn btn-submit" id="J_Submit">确认留言</a>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!--弹窗-->
        <div class="lspop-wrap">
            <div class="lspop" id="lsPop">
                <div>您的信息已提交...</div>
            </div>
        </div>
        <!--内容 end-->
        <include file="Public/footer"/>
    </div>
</body>
<script type="text/javascript">
    $(document).ready(function(){
        var popTimer;
        $("#J_Submit").on('click', function(){
            var phone = $.trim($("#phone").val());
            var user_name = $.trim($("#user_name").val());
            var content = $.trim($("#content").val());
            if (phone == "") {
                alert("电话不能为空!");
                return;
            }
            if (user_name == "") {
                alert("用户名不能为空!");
                return;
            }
            if (content == "") {
                alert("内容不能为空!");
                return;
            }
            $.ajax({
                type: 'post',
                url:'<?php echo U('Forum/add'); ?>',
                dataType: 'json',
                data: {
                    topic_id: "<?php echo $topic_id; ?>",
                    user_name: user_name,
                    phone: phone,
                    content: content,
                },
                beforeSubmit: function(arr, from,options) {
                    return true;
                },
                success: function(data, statusText) {
                    if (data.code == '1000') {
                        $("#lsPop").show();
                        location.reload();
                    } else {
                        alert(data.msg);
                        return false;
                    }
                },
                error: function(xhr, textStatus, errorThrown){
                    alert('提交失败！');
                }
            });
        });
    });
</script>
</html>